//
//  BluetoothListCell.m
//  Spinning
//
//  Created by zl on 2018/2/27.
//  Copyright © 2018年 com. All rights reserved.
//

#import "BluetoothListCell.h"
#import <BabyBluetooth/BabyBluetooth.h>

@interface BluetoothListCell()



@end

@implementation BluetoothListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}

- (void)createUI {
    
    self.breakBtn = [UIButton buttonWithframe:CGRectMake(280.0f * scaleX-60, 0, 60, 44) text:@"断开" font:[UIFont systemFontOfSize:17] textColor:@"#EF9B39" backgroundColor:nil normal:nil selected:nil];
    [self.breakBtn addTarget:self action:@selector(breakBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_breakBtn];
    
    self.nameLabel = [UILabel labelWithframe:CGRectMake(15, 0, self.breakBtn.left-15, self.breakBtn.height) text:@"" font:[UIFont systemFontOfSize:17] textAlignment:NSTextAlignmentLeft textColor:@"#000000"];
    [self.contentView addSubview:_nameLabel];
    

    
}



- (void)breakBtnAction:(UIButton *)sender {
    NSLog(@"row:%ld",self.row);
    if ([self.delegate respondsToSelector:@selector(breakBtnResponderWithRow:)]) {
        [self.delegate breakBtnResponderWithRow:self.row];
    }
}

//- (void)setNameStr:(NSString *)nameStr {
//    _nameStr = nameStr;
//    self.nameLabel.text = nameStr;
//}
//
//- (void)setIsSelected:(BOOL)isSelected {
//    _isSelected = isSelected;
//    if (isSelected) {
//        _breakBtn.hidden = NO;
//        NSLog(@"断开按钮不隐藏");
//    }else {
//        _breakBtn.hidden = YES;
//        NSLog(@"断开按钮隐藏");
//
//    }
//}

//- (void)setModel:(CBPeripheral *)model {
//    _model = model;
//    self.nameLabel.text = model.name;
//    switch (model.state) {
//        case CBPeripheralStateDisconnected:
//            _breakBtn.hidden = YES;
//            break;
//        case CBPeripheralStateDisconnecting:
//            _breakBtn.hidden = YES;
//            break;
//        case CBPeripheralStateConnected:
//            _breakBtn.hidden = NO;
//            break;
//        case CBPeripheralStateConnecting:
//            _breakBtn.hidden = NO;
//            break;
//
//        default:
//            break;
//    }
//}
@end
